/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.casestudy1.yuh;

import com.casestudy1.main.MainMidlet;
import com.casestudy1.view.BlockedTrafficForm;
import com.casestudy1.view.View;
import com.sun.lwuit.Button;
import com.sun.lwuit.ComboBox;
import com.sun.lwuit.Command;
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Form;
import com.sun.lwuit.List;
import com.sun.lwuit.RadioButton;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.events.SelectionListener;
import com.sun.lwuit.list.ContainerList;
import java.io.IOException;
import java.util.Vector;
import javax.microedition.media.MediaException;
import javax.microedition.midlet.MIDlet;

/**
 *
 * @author Huy
 */
public class ListTrafficInfoForm extends View{
    private MIDlet midlet;
    private List list;
    private Command cmd_back;
    
    public ListTrafficInfoForm(final MainMidlet midlet, String local) {
        super(midlet);
        final Vector v = new connServer().getAtLocal(local);
        list = new List();
        
        for(int i=0;i<v.size();i++){
            trafficReport tr = (trafficReport) v.elementAt(i);
            list.addItem(tr.getVitri() + " - " +tr.getKhuvuc());
        }
        
        list.addSelectionListener(new SelectionListener() {

            public void selectionChanged(int i, int i1) {
                new TrafficReportDetailForm(midlet, (trafficReport)v.elementAt(i1)).show();
            }
        });
        
        addComponent(list);
        
        cmd_back = new Command("Back"){

            public void actionPerformed(ActionEvent evt) {
                try {
                    new BlockedTrafficForm(midlet).show();
                } catch (IOException ex) {
                    ex.printStackTrace();
                } catch (MediaException ex) {
                    ex.printStackTrace();
                }
            }
            
        };
        
        setBackCommand(cmd_back);
        addCommand(cmd_back);
    }
    
    
}
